using System.Collections.Generic;
using System.Threading.Tasks;
using JGSY.CMS.LowCode.Platform.Domain.Entities;

namespace JGSY.CMS.LowCode.Platform.Domain.Interfaces
{
    /// <summary>
    /// 角色仓储接口
    /// 提供系统角色的数据访问操作，支持角色管理和权限分配功能
    /// </summary>
    public interface IRoleRepository
    {
        /// <summary>
        /// 获取所有角色记录
        /// </summary>
        /// <returns>角色实体列表</returns>
        Task<IEnumerable<Role>> GetAllAsync();
        
        /// <summary>
        /// 根据ID获取角色记录
        /// </summary>
        /// <param name="id">角色标识符</param>
        /// <returns>角色实体，如果未找到则返回null</returns>
        Task<Role?> GetByIdAsync(long id);
        
        /// <summary>
        /// 添加新角色
        /// </summary>
        /// <param name="entity">要添加的角色实体</param>
        /// <returns>添加操作任务</returns>
        Task AddAsync(Role entity);
        
        /// <summary>
        /// 更新角色信息
        /// </summary>
        /// <param name="entity">更新后的角色实体</param>
        /// <returns>更新操作任务</returns>
        Task UpdateAsync(Role entity);
        
        /// <summary>
        /// 删除角色
        /// </summary>
        /// <param name="id">角色标识符</param>
        /// <returns>删除操作任务</returns>
        Task DeleteAsync(long id);
        
        /// <summary>
        /// 为角色分配权限
        /// </summary>
        /// <param name="roleId">角色标识符</param>
        /// <param name="permissionIds">要分配的权限标识符列表</param>
        /// <returns>权限分配操作任务</returns>
        Task AssignPermissionsAsync(long roleId, List<long> permissionIds);
        
        /// <summary>
        /// 获取角色的权限列表
        /// </summary>
        /// <param name="roleId">角色标识符</param>
        /// <returns>角色关联的权限实体列表</returns>
        Task<IEnumerable<Permission>> GetPermissionsAsync(long roleId);
    }
}
